package org.gdufe.auth.controller;

import org.gdufe.auth.service.UserService;
import org.gdufe.pojos.dto.InsertUserDto;
import org.gdufe.pojos.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/auth")
public class AuthTestController {

    @Autowired
    private UserService userService;

    @RequestMapping("/r/r1")
    @PreAuthorize("hasAuthority('test')")//权限控制
    public String authtest(){
        return "auth-service auth success";
    }

    @RequestMapping("/login-success")
    public String loginSuccess(){
        return "login success";
    }

    @PostMapping ("/regist")
    public R regist(@RequestBody InsertUserDto insertUserDto){
        System.out.println("regist");
        return userService.regist(insertUserDto);
    }
}
